import Taro, { Component } from "@tarojs/taro";
import { View, Image } from "@tarojs/components";
import {getRuntime} from '../../utils/common'

import '../mall/mall.less'
import success_icon from '../../assets/img/icon_29.png'
import address from "../../assets/img/icon_59.png";

interface orderInfo {
  defaultAddress: object,
  orderId: number,
  orderTotalAmount: string
}

class Success extends Component{
  constructor(props){
    super(props)
  }

  state = {
    orderInfo: {}
  }

  componentWillMount(): void {
    Taro.setNavigationBarTitle({ title:'升级成功' })
    let orderInfo:orderInfo =  getRuntime().getStorage('orderInfo') || {
      defaultAddress: {},
      orderId: 0,
      orderTotalAmount: 0
    }
    this.setState({
      orderInfo
    })
  }

  handelRouter(url: string = '/pages/index/index'): void {
    getRuntime().navigateTo(url)
  }

  render() {
    let { orderInfo } = this.state
    return(
      <View className='pay-success'>
        <View className='apply-success'>
          <View className='content'>
            <Image className='success-icon' src={success_icon} />
            <View className='title'>支付成功</View>
          </View>

          <View className='interval' />

          <View className='btn-line-submit' onClick={this.handelRouter.bind(this,'/pages/user/index')}>
            返回会员中心
          </View>
        </View>
      </View>
    )
  }
}

export default Success
